/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InternalDeliveryFrame.java
 *
 * Created on 08 Apr 13, 20:36:51
 */
package com.ivanbiz.gui;

import com.ivanbiz.dao.CabangDAO;
import com.ivanbiz.dao.GudangItemDAO;
import com.ivanbiz.dao.InternalDeliveryDAO;
import com.ivanbiz.dao.InternalDeliveryItemDAO;
import com.ivanbiz.dao.impl.CabangDAOImpl;
import com.ivanbiz.dao.impl.GudangItemDAOImpl;
import com.ivanbiz.dao.impl.InternalDeliveryDAOImpl;
import com.ivanbiz.dao.impl.InternalDeliveryItemDAOImpl;
import com.ivanbiz.helper.GlobalConstant;
import com.ivanbiz.helper.MyUniqueNumber;
import com.ivanbiz.helper.ServiceHelper;
import com.ivanbiz.helper.UserSession;
import com.ivanbiz.model.Cabang;
import com.ivanbiz.model.GudangItem;
import com.ivanbiz.model.InternalDelivery;
import com.ivanbiz.model.InternalDeliveryItem;
import com.ivanbiz.model.User;
import com.ivanbiz.report.InternalDeliveryReport;
import java.awt.event.KeyEvent;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

/**
 *
 * @author Shbt Peterpan
 */
public class InternalDeliveryFrame extends javax.swing.JInternalFrame {

    InternalDeliveryDAO internalDeliveryDAO = new InternalDeliveryDAOImpl();
    InternalDeliveryItemDAO internalDeliveryItemDAO = new InternalDeliveryItemDAOImpl();
    CabangDAO cabangDAO = new CabangDAOImpl();
    List<InternalDelivery> listInternalDelivery = new ArrayList<InternalDelivery>();
    List<InternalDeliveryItem> listInternalDeliveryItem = new ArrayList<InternalDeliveryItem>();
    List<Cabang> listCabang = new ArrayList<Cabang>();
    GudangItemDAO gudangItemDAO = new GudangItemDAOImpl();
    User user = UserSession.getUser();
    NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
    ServiceHelper serviceHelper = new ServiceHelper();

    /** Creates new form InternalDeliveryFrame */
    public InternalDeliveryFrame() {
        setVisible(true);
        initComponents();
        listInternalDeliveryItem.clear();
        updateData();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        textNoDelivery = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        comboCabang = new javax.swing.JComboBox();
        dateTanggalKirim = new org.jdesktop.swingx.JXDatePicker();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tableData = new javax.swing.JTable();
        jPanel6 = new javax.swing.JPanel();
        buttonDelete = new javax.swing.JButton();
        buttonUpdate = new javax.swing.JButton();
        buttonReset = new javax.swing.JButton();
        buttonSave = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        buttonDelete1 = new javax.swing.JButton();
        buttonUpdate1 = new javax.swing.JButton();
        buttonReset1 = new javax.swing.JButton();
        buttonSave1 = new javax.swing.JButton();
        buttonPrint = new javax.swing.JButton();
        jPanel11 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tableData1 = new javax.swing.JTable();
        jPanel13 = new javax.swing.JPanel();
        jLabel35 = new javax.swing.JLabel();
        textKodeBarcode = new javax.swing.JTextField();
        jLabel36 = new javax.swing.JLabel();
        textHargaModal = new javax.swing.JTextField();
        jLabel37 = new javax.swing.JLabel();
        textQuantity = new javax.swing.JTextField();
        jLabel38 = new javax.swing.JLabel();
        textNamaItem = new javax.swing.JTextField();
        jPanel5 = new javax.swing.JPanel();
        comboSearch = new javax.swing.JComboBox();
        textSearch = new javax.swing.JTextField();
        jPanel14 = new javax.swing.JPanel();
        jLabel40 = new javax.swing.JLabel();
        comboNoDelivery = new javax.swing.JComboBox();
        jLabel39 = new javax.swing.JLabel();
        dateTanggalTerima = new org.jdesktop.swingx.JXDatePicker();

        jTabbedPane1.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Input", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel1.setText("No Delivery");

        textNoDelivery.setFont(new java.awt.Font("Monospaced", 1, 14));

        jLabel2.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel2.setText("Tanggal Kirim");

        jLabel4.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel4.setText("Cabang");

        comboCabang.setFont(new java.awt.Font("Monospaced", 1, 14));

        dateTanggalKirim.setFont(new java.awt.Font("Monospaced", 1, 14));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4))
                .addGap(7, 7, 7)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(dateTanggalKirim, javax.swing.GroupLayout.DEFAULT_SIZE, 609, Short.MAX_VALUE)
                    .addComponent(comboCabang, javax.swing.GroupLayout.Alignment.LEADING, 0, 609, Short.MAX_VALUE)
                    .addComponent(textNoDelivery, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 609, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(textNoDelivery, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(dateTanggalKirim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(comboCabang, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Table Data", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        tableData.setAutoCreateRowSorter(true);
        tableData.setFont(new java.awt.Font("Monospaced", 1, 14));
        tableData.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tableData.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableDataMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tableData);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 720, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Button", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        buttonDelete.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/delete.jpg"))); // NOI18N
        buttonDelete.setText("Hapus");
        buttonDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonDeleteActionPerformed(evt);
            }
        });

        buttonUpdate.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonUpdate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Edit.jpg"))); // NOI18N
        buttonUpdate.setText("Edit");
        buttonUpdate.setPreferredSize(new java.awt.Dimension(70, 23));
        buttonUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonUpdateActionPerformed(evt);
            }
        });

        buttonReset.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Reset.jpg"))); // NOI18N
        buttonReset.setText("Reset");
        buttonReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonResetActionPerformed(evt);
            }
        });

        buttonSave.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/save.jpg"))); // NOI18N
        buttonSave.setText("Simpan");
        buttonSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSaveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buttonSave, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonUpdate, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonDelete, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonReset, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonReset, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonDelete, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonSave, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Internal Delivery", jPanel4);

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Button", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        buttonDelete1.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonDelete1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/delete.jpg"))); // NOI18N
        buttonDelete1.setText("Hapus");
        buttonDelete1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonDelete1ActionPerformed(evt);
            }
        });

        buttonUpdate1.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonUpdate1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Edit.jpg"))); // NOI18N
        buttonUpdate1.setText("Edit");
        buttonUpdate1.setPreferredSize(new java.awt.Dimension(70, 23));
        buttonUpdate1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonUpdate1ActionPerformed(evt);
            }
        });

        buttonReset1.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonReset1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Reset.jpg"))); // NOI18N
        buttonReset1.setText("Reset");
        buttonReset1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonReset1ActionPerformed(evt);
            }
        });

        buttonSave1.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonSave1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/save.jpg"))); // NOI18N
        buttonSave1.setText("Simpan");
        buttonSave1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSave1ActionPerformed(evt);
            }
        });

        buttonPrint.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        buttonPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Print.jpg"))); // NOI18N
        buttonPrint.setText("Print");
        buttonPrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonPrintActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buttonSave1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonUpdate1, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonDelete1, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonReset1, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonPrint, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonReset1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonDelete1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonUpdate1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonSave1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonPrint, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Table Data", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        tableData1.setAutoCreateRowSorter(true);
        tableData1.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        tableData1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tableData1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableData1MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tableData1);

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 720, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 76, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Input", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        jLabel35.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel35.setText("Kode Barcode");

        textKodeBarcode.setEditable(false);
        textKodeBarcode.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N

        jLabel36.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel36.setText("Nama Item");

        textHargaModal.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N

        jLabel37.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel37.setText("Harga Modal");

        textQuantity.setFont(new java.awt.Font("Monospaced", 1, 14));

        jLabel38.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel38.setText("Quantity");

        textNamaItem.setEditable(false);
        textNamaItem.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel35)
                    .addComponent(jLabel36)
                    .addComponent(jLabel37)
                    .addComponent(jLabel38))
                .addGap(26, 26, 26)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(textNamaItem, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
                    .addComponent(textKodeBarcode, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
                    .addComponent(textQuantity, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
                    .addComponent(textHargaModal, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel35)
                    .addComponent(textKodeBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel36)
                    .addComponent(textNamaItem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel37)
                    .addComponent(textHargaModal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel38)
                    .addComponent(textQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        comboSearch.setFont(new java.awt.Font("Monospaced", 1, 14));

        textSearch.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        textSearch.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textSearchKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(comboSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 237, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textSearch, javax.swing.GroupLayout.DEFAULT_SIZE, 477, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Input", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        jLabel40.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel40.setText("No Delivery");

        comboNoDelivery.setFont(new java.awt.Font("Monospaced", 1, 14));
        comboNoDelivery.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                comboNoDeliveryItemStateChanged(evt);
            }
        });
        comboNoDelivery.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                comboNoDeliveryKeyPressed(evt);
            }
        });

        jLabel39.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        jLabel39.setText("Tanggal Terima");

        dateTanggalTerima.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel40)
                    .addComponent(jLabel39))
                .addGap(10, 10, 10)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(dateTanggalTerima, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
                    .addComponent(comboNoDelivery, 0, 598, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboNoDelivery, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel40))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel39)
                    .addComponent(dateTanggalTerima, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Internal Delivery Item", jPanel3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 616, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buttonDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDeleteActionPerformed
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            try {
                InternalDelivery internalDelivery = (InternalDelivery) listInternalDelivery.get(tableData.getSelectedRow());
                internalDeliveryDAO.delete(internalDelivery);
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_DELETE);
                updateData();
            } catch (Exception ex) {
                Logger.getLogger(InternalDeliveryFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_buttonDeleteActionPerformed

    private void buttonUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpdateActionPerformed
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            try {
                InternalDelivery internalDelivery = listInternalDelivery.get(tableData.getSelectedRow());
                internalDelivery.setNomorInternalDelivery(textNoDelivery.getText());
                internalDelivery.setTanggalKirim(serviceHelper.getDateFormat(dateTanggalKirim.getDate()));
                internalDelivery.setCabang((Cabang) listCabang.get(comboCabang.getSelectedIndex()));
                internalDelivery.setStatus(GlobalConstant.N);
                internalDelivery.setUpdatedBy(user.getUserName());
                internalDelivery.setUpdatedDate(new Date());
                internalDeliveryDAO.update(internalDelivery);
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_SAVE);
                updateData();
            } catch (Exception ex) {
                Logger.getLogger(InternalDeliveryFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_buttonUpdateActionPerformed

    private void buttonResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonResetActionPerformed
        updateData();
}//GEN-LAST:event_buttonResetActionPerformed

    private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveActionPerformed
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            try {
                InternalDelivery status = (InternalDelivery) internalDeliveryDAO.getDataByEqual(InternalDelivery.class, "nomorInternalDelivery", textNoDelivery.getText());
                if (null != status) {
                    JOptionPane.showMessageDialog(this, jLabel1.getText() + GlobalConstant.SPACE + GlobalConstant.MSG_EXIST);
                } else {
                    InternalDelivery internalDelivery = new InternalDelivery();
                    internalDelivery.setNomorInternalDelivery(textNoDelivery.getText());
                    internalDelivery.setTanggalKirim(serviceHelper.getDateFormat(dateTanggalKirim.getDate()));
                    internalDelivery.setCabang((Cabang) listCabang.get(comboCabang.getSelectedIndex()));
                    internalDelivery.setStatus(GlobalConstant.N);
                    internalDelivery.setCreatedBy(user.getUserName());
                    internalDelivery.setCreatedDate(new Date());
                    internalDeliveryDAO.save(internalDelivery);
                    JOptionPane.showMessageDialog(this, GlobalConstant.MSG_SAVE);
                    updateData();
                }
            } catch (Exception ex) {
                Logger.getLogger(InternalDeliveryFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_buttonSaveActionPerformed

    private void tableDataMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableDataMouseClicked
        InternalDelivery internalDelivery = (InternalDelivery) listInternalDelivery.get(tableData.getSelectedRow());
        textNoDelivery.setText(internalDelivery.getNomorInternalDelivery());
        dateTanggalKirim.setDate(internalDelivery.getTanggalKirim());
        comboCabang.setSelectedItem(internalDelivery.getCabang().getNama());
    }//GEN-LAST:event_tableDataMouseClicked

    private void buttonDelete1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDelete1ActionPerformed
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            try {
                InternalDeliveryItem internalDeliveryItem = (InternalDeliveryItem) listInternalDeliveryItem.get(tableData1.getSelectedRow());
                internalDeliveryItemDAO.delete(internalDeliveryItem);
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_DELETE);
                listInternalDeliveryItem = internalDeliveryItemDAO.getDataByEquals(InternalDeliveryItem.class, "nomorInternalDelivery", (String) comboNoDelivery.getSelectedItem());
                updateData();
            } catch (Exception ex) {
                Logger.getLogger(InternalDeliveryFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_buttonDelete1ActionPerformed

    private void buttonUpdate1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpdate1ActionPerformed
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            try {
                InternalDeliveryItem internalDeliveryItem = (InternalDeliveryItem) listInternalDeliveryItem.get(tableData1.getSelectedRow());
                internalDeliveryItem.setKodeBarcode(textKodeBarcode.getText());
                internalDeliveryItem.setNamaItem(textNamaItem.getText());
                internalDeliveryItem.setHargaModal(Double.parseDouble(textHargaModal.getText()));
                internalDeliveryItem.setQuantity(Long.parseLong(textQuantity.getText()));
                internalDeliveryItem.setDateReceive(serviceHelper.getDateFormat(dateTanggalTerima.getDate()));
                internalDeliveryItem.setNomorInternalDelivery((String) comboNoDelivery.getSelectedItem());
                internalDeliveryItem.setUpdatedBy(user.getUserName());
                internalDeliveryItem.setUpdatedDate(new Date());
                internalDeliveryItemDAO.update(internalDeliveryItem);
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_UPDATE);
                listInternalDeliveryItem = internalDeliveryItemDAO.getDataByEquals(InternalDeliveryItem.class, "nomorInternalDelivery", (String) comboNoDelivery.getSelectedItem());
                updateData();
            } catch (Exception ex) {
                Logger.getLogger(InternalDeliveryFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_buttonUpdate1ActionPerformed

    private void buttonReset1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReset1ActionPerformed
        listInternalDeliveryItem.clear();
        updateData();
}//GEN-LAST:event_buttonReset1ActionPerformed

    private void buttonSave1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSave1ActionPerformed
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            try {
                InternalDeliveryItem internalDeliveryItem = new InternalDeliveryItem();
                internalDeliveryItem.setKodeBarcode(textKodeBarcode.getText());
                internalDeliveryItem.setNamaItem(textNamaItem.getText());
                internalDeliveryItem.setHargaModal(Double.parseDouble(textHargaModal.getText()));
                internalDeliveryItem.setQuantity(Long.parseLong(textQuantity.getText()));
                internalDeliveryItem.setDateReceive(serviceHelper.getDateFormat(dateTanggalTerima.getDate()));
                internalDeliveryItem.setNomorInternalDelivery((String) comboNoDelivery.getSelectedItem());
                internalDeliveryItem.setCreatedBy(user.getUserName());
                internalDeliveryItem.setCreatedDate(new Date());
                internalDeliveryItemDAO.save(internalDeliveryItem);
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_SAVE);
                listInternalDeliveryItem = internalDeliveryItemDAO.getDataByEquals(InternalDeliveryItem.class, "nomorInternalDelivery", (String) comboNoDelivery.getSelectedItem());
                updateData();
            } catch (Exception ex) {
                Logger.getLogger(InternalDeliveryFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_buttonSave1ActionPerformed

    private void tableData1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableData1MouseClicked
        InternalDeliveryItem internalDeliveryItem = (InternalDeliveryItem) listInternalDeliveryItem.get(tableData1.getSelectedRow());
        textKodeBarcode.setText(internalDeliveryItem.getKodeBarcode());
        textNamaItem.setText(internalDeliveryItem.getNamaItem());
        textHargaModal.setText(String.valueOf(internalDeliveryItem.getHargaModal()));
        textQuantity.setText(String.valueOf(internalDeliveryItem.getQuantity()));
        comboNoDelivery.setSelectedItem(internalDeliveryItem.getNomorInternalDelivery());
        dateTanggalTerima.setDate(internalDeliveryItem.getDateReceive());
}//GEN-LAST:event_tableData1MouseClicked

    private void textSearchKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textSearchKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            try {
                GudangItem gudangItem = (GudangItem) gudangItemDAO.getDataByEqual(GudangItem.class, (String) comboSearch.getSelectedItem(), textSearch.getText());
                if (gudangItem != null) {
                    textKodeBarcode.setText(gudangItem.getKodeBarcode());
                    textNamaItem.setText(gudangItem.getNamaItem());
                    textHargaModal.setText(String.valueOf(gudangItem.getHargaModal()));
                    textQuantity.setText(String.valueOf(gudangItem.getStock()));
                } else {
                    JOptionPane.showMessageDialog(this, (String) comboSearch.getSelectedItem() + GlobalConstant.SPACE + GlobalConstant.MSG_NOT_EXIST);
                }
            } catch (Exception ex) {
                Logger.getLogger(InternalDeliveryFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
//        try {
//            listInternalDeliveryItem = internalDeliveryItemDAO.getDataByLike(InternalDeliveryItem.class, (String) comboSearch.getSelectedItem(), textSearch.getText());
//            updateTable1();
//        } catch (Exception ex) {
//            Logger.getLogger(InternalDeliveryFrame.class.getName()).log(Level.SEVERE, null, ex);
//        }
}//GEN-LAST:event_textSearchKeyReleased

    private void buttonPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPrintActionPerformed
        try {
            List<InternalDeliveryItem> listNoDelivery = internalDeliveryItemDAO.getDataByEquals(InternalDeliveryItem.class, "nomorInternalDelivery", (String) comboNoDelivery.getSelectedItem());
            InternalDelivery listNoD = (InternalDelivery) internalDeliveryDAO.getDataByEqual(InternalDelivery.class, "nomorInternalDelivery", (String) comboNoDelivery.getSelectedItem());
            InternalDeliveryReport internalDeliveryReport = new InternalDeliveryReport();
            internalDeliveryReport.printInternalDeliveryItem(listNoDelivery, listNoD);
            updateData();
        } catch (Exception ex) {
            Logger.getLogger(InternalDeliveryFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_buttonPrintActionPerformed

    private void comboNoDeliveryKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_comboNoDeliveryKeyPressed
        try {
            listInternalDeliveryItem = internalDeliveryItemDAO.getDataByEquals(InternalDeliveryItem.class, "nomorInternalDelivery", (String) comboNoDelivery.getSelectedItem());
            updateTable1();
        } catch (Exception ex) {
            Logger.getLogger(InternalDeliveryFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_comboNoDeliveryKeyPressed

    private void comboNoDeliveryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboNoDeliveryItemStateChanged
        try {
            listInternalDeliveryItem = internalDeliveryItemDAO.getDataByEquals(InternalDeliveryItem.class, "nomorInternalDelivery", (String) comboNoDelivery.getSelectedItem());
            updateTable1();
        } catch (Exception ex) {
            Logger.getLogger(InternalDeliveryFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_comboNoDeliveryItemStateChanged
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonDelete;
    private javax.swing.JButton buttonDelete1;
    private javax.swing.JButton buttonPrint;
    private javax.swing.JButton buttonReset;
    private javax.swing.JButton buttonReset1;
    private javax.swing.JButton buttonSave;
    private javax.swing.JButton buttonSave1;
    private javax.swing.JButton buttonUpdate;
    private javax.swing.JButton buttonUpdate1;
    private javax.swing.JComboBox comboCabang;
    private javax.swing.JComboBox comboNoDelivery;
    private javax.swing.JComboBox comboSearch;
    private org.jdesktop.swingx.JXDatePicker dateTanggalKirim;
    private org.jdesktop.swingx.JXDatePicker dateTanggalTerima;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable tableData;
    private javax.swing.JTable tableData1;
    private javax.swing.JTextField textHargaModal;
    private javax.swing.JTextField textKodeBarcode;
    private javax.swing.JTextField textNamaItem;
    private javax.swing.JTextField textNoDelivery;
    private javax.swing.JTextField textQuantity;
    private javax.swing.JTextField textSearch;
    // End of variables declaration//GEN-END:variables

    private void updateData() {
        try {
            clearData();
            listInternalDelivery = internalDeliveryDAO.getDataByEquals(InternalDelivery.class, "status", GlobalConstant.N);
            // = internalDeliveryItemDAO.getAll(InternalDeliveryItem.class);
            listCabang = cabangDAO.getAll(Cabang.class);
            updateTable();
            updateTable1();
            updateCombo();
            updateComboNoDelivery();
            updateComboCari();
        } catch (Exception ex) {
            Logger.getLogger(InternalDeliveryFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void clearData() {
        MyUniqueNumber myUniqueNumber = new MyUniqueNumber();
        myUniqueNumber.setDateUniqueNumberInternalDelivery();
        textNoDelivery.setText(myUniqueNumber.getNoInternalDelivery());
        dateTanggalKirim.setDate(new Date());
        textKodeBarcode.setText(GlobalConstant.EMPTY_STRING);
        textNamaItem.setText(GlobalConstant.EMPTY_STRING);
        textHargaModal.setText(GlobalConstant.EMPTY_STRING);
        textQuantity.setText(GlobalConstant.EMPTY_STRING);
        dateTanggalTerima.setDate(new Date());
        buttonUpdate.setVisible(false);
        jLabel39.setVisible(false);
        dateTanggalTerima.setVisible(false);
        buttonUpdate1.setVisible(false);
        buttonPrint.setVisible(false);
    }

    private void updateTable() {
        String[] judul = {GlobalConstant.NO, jLabel1.getText(), jLabel2.getText(), jLabel4.getText()};
        Object[][] isi = new Object[listInternalDelivery.size()][4];
        int x = 0;
        int no = 0;
        for (InternalDelivery internalDelivery : listInternalDelivery) {
            isi[x][0] = no += 1;
            isi[x][1] = internalDelivery.getNomorInternalDelivery();
            isi[x][2] = internalDelivery.getTanggalKirim();
            isi[x][3] = internalDelivery.getCabang().getNama();
            x++;
        }
        tableData.setModel(new DefaultTableModel(isi, judul) {

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return false;
            }
        });

        TableColumn column0 = tableData.getColumnModel().getColumn(0);
        column0.setPreferredWidth(75);
        column0.setMaxWidth(75);
        TableColumn column1 = tableData.getColumnModel().getColumn(1);
        column1.setPreferredWidth(150);
        column1.setMaxWidth(150);
        TableColumn column2 = tableData.getColumnModel().getColumn(2);
        column2.setPreferredWidth(200);
        column2.setMaxWidth(200);
    }

    private void updateCombo() {
        Object data[] = new Object[listCabang.size()];
        int x = 0;
        for (Cabang cabang : listCabang) {
            data[x] = cabang.getNama();
            x++;
        }
        comboCabang.setModel(new DefaultComboBoxModel(data));
    }

    private void updateTable1() {
        String[] judul = {GlobalConstant.NO, jLabel40.getText(), jLabel35.getText(), jLabel36.getText(), jLabel37.getText(), jLabel38.getText(), jLabel39.getText()};
        Object[][] isi = new Object[listInternalDeliveryItem.size()][7];
        int x = 0;
        int no = 0;
        for (InternalDeliveryItem internalDeliveryItem : listInternalDeliveryItem) {
            isi[x][0] = no += 1;
            isi[x][1] = internalDeliveryItem.getNomorInternalDelivery();
            isi[x][2] = internalDeliveryItem.getKodeBarcode();
            isi[x][3] = internalDeliveryItem.getNamaItem();
            isi[x][4] = numberFormat.format(internalDeliveryItem.getHargaModal());
            isi[x][5] = internalDeliveryItem.getQuantity();
            isi[x][6] = internalDeliveryItem.getDateReceive();
            x++;
        }
        tableData1.setModel(new DefaultTableModel(isi, judul) {

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return false;
            }
        });

        TableColumn column0 = tableData1.getColumnModel().getColumn(0);
        column0.setPreferredWidth(75);
        column0.setMaxWidth(75);
        TableColumn column1 = tableData1.getColumnModel().getColumn(1);
        column1.setPreferredWidth(150);
        column1.setMaxWidth(150);
        TableColumn column2 = tableData1.getColumnModel().getColumn(2);
        column2.setPreferredWidth(150);
        column2.setMaxWidth(150);
        TableColumn column4 = tableData1.getColumnModel().getColumn(4);
        column4.setPreferredWidth(150);
        column4.setMaxWidth(150);
        TableColumn column5 = tableData1.getColumnModel().getColumn(5);
        column5.setPreferredWidth(75);
        column5.setMaxWidth(75);
        TableColumn column6 = tableData1.getColumnModel().getColumn(6);
        column6.setPreferredWidth(200);
        column6.setMaxWidth(200);
    }

    private void updateComboNoDelivery() {
        Object data[] = new Object[listInternalDelivery.size()];
        int x = 0;
        for (InternalDelivery internalDelivery : listInternalDelivery) {
            data[x] = internalDelivery.getNomorInternalDelivery();
            x++;
        }
        comboNoDelivery.setModel(new DefaultComboBoxModel(data));
    }

    private void updateComboCari() {
        Object[] dataClass = serviceHelper.getPropertyClass(InternalDeliveryItem.class);
        Object[] dataSearch = new Object[2];
        dataSearch[0] = dataClass[1];
        dataSearch[1] = dataClass[2];
        comboSearch.setModel(new DefaultComboBoxModel(dataSearch));
    }
}
